<template>
	<view class="login">
		<form class="lg-form" @submit="doLogin">
			<label>用户名</label>
			<input name="username" v-model="username" placeholder="请输入用户名" />
			<label>验证码</label>
			<input name="phoneValid" v-model="phoneValid" placeholder="请输入验证码" />
			<button formType="submit">登录</button>
		</form>
		<button open-type="getUserInfo" @getuserinfo="l">wx</button>
	</view>
</template>

<script>

	import {
		mapState,
		mapActions
	} from 'vuex'
	import navigator from '../../common/navigator/navigator.js'
	function l(res) {
		console.log(res)
	}
	
	export default {
		data() {
			return {
				username: '18017628732',
				phoneValid: '111111'
			};
		},
		methods: {
			async doLogin (e) {
				console.log(e)
				let t = await this.login(e.detail.value)
				console.log(t)
				navigator.goto('/pages/home/home?test=1', {key: t}, false)
			},
			wxlogin () {
				uni.login({
					provider: 'weixin',
					success(res) {
						console.log(res)
					}
				})
			},
			l (res) {
				console.log(res)
			},
			...mapActions(['login'])
		}
	}
</script>

<style lang="scss">

</style>
